home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
LIFER__
/
PROTO
/
P
/
PA_LIFE_.C
< prev
next >
Wrap
Text File
|
1991-07-23
|
5KB
|
130 lines
/* PA_Life_Alert Handle this alert */
/* File name: PA_Life_Alert.c */
/* Function: Handle this alert. */
/* This is a NOTE alert, it is used to inform the user of some general information. */
/* This alert is not used if there is a possibility of losing any data. */
/* This alert is called when: */
/* */
/* The choices in this alert allow for: */
/* */
/* History: 7/23/91 Original by Prototyper 3.0 */
#include "PCommonLife.h" /* Common */
#include "Common_Life.h" /* Common */
#include "PUtils_Life.h" /* General Utilities */
#include "Utils_Life.h" /* General Utilities */
#include "PA_Life_Alert.h" /* This file */
#include "Life_Alert.h" /* Users specific file */
static Boolean FirstTime; /* Flag for first time thru the filter */
/* Prototype for filter routine */
static pascal Boolean MyFilter (DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
/* ======================================================= */
/* Filter routine, also used for initial setup of dimmed states */
static pascal Boolean MyFilter (theDialog,theEvent,itemHit)
DialogPtr theDialog;
EventRecord *theEvent;
short *itemHit;
{
Boolean FilterValue; /* Temporary return value */
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
short chCode; /* Key entered */
long LTemp; /* Used for time delay and HotSpot definitions */
FilterValue = FALSE;
if (FirstTime == TRUE) /* Make all controls and do lines and rects */
{
GetDItem(theDialog,Res_Alrt_ReEnter,&DType,&DItem,&tempRect);/* Get the item handle */
PenSize(3, 3); /* Change pen to draw thick default outline */
InsetRect(&tempRect, -4, -4); /* Draw outside the button by 1 pixel */
FrameRoundRect(&tempRect, 16, 16); /* Draw the outline */
PenSize(1, 1); /* Restore the pen size to the default value */
FirstTime = FALSE; /* Not first time anymore */
}
FilterValue = Filter_Life_Alert(theDialog, theEvent, itemHit);/* Call the user routine */
if (theEvent->what == keyDown)
{
chCode = (theEvent->message & charCodeMask);/* Get character */
if ((chCode == 13) || (chCode == 0x03)) /* CR or Enter */
{
FilterValue = TRUE; /* Flag we got a hit */
*itemHit = 1; /* Default for CR */
GetDItem (theDialog ,*itemHit, &DType, &DItem, &tempRect);/* Get the item */
if (DType == (ctrlItem + btnCtrl)) /* If a button then ... */
{
CItem = (ControlHandle) DItem; /* Make it a controlhandle */
HiliteControl(CItem, 10); /* Hilite it */
LTemp = TickCount() + 15; /* Flash the button for 1/4 second */
do
{}
while (LTemp > TickCount());
HiliteControl(CItem, 0); /* UnHilite it */
}
}
}
return(FilterValue);
}
/* ======================================================= */
void I_PA_Life_Alert()
{
A_Init_Life_Alert();
} /* End of procedure */
/* ======================================================= */
void PA_Life_Alert()
{
short itemHit; /* Get the selection ID in here */
AlertTHndl AlertResHandle; /* Resource handle for Alert */
Rect tempRect; /* Temp rect for moving the alert */
AlertResHandle = (AlertTHndl)GetResource('ALRT', Res_A_Life_Alert);/* Get the Alerts resource template handle */
HLock((Handle)AlertResHandle); /* Lock the resource down while we use it */
tempRect = (*AlertResHandle)->boundsRect; /* Get the alerts position and size */
tempRect.left = ((screenBits.bounds.right - screenBits.bounds.left) - (tempRect.right - tempRect.left)) / 2;/* Center Horz */
tempRect.bottom = tempRect.top + ((*AlertResHandle)->boundsRect.bottom - (*AlertResHandle)->boundsRect.top);
tempRect.right = tempRect.left + ((*AlertResHandle)->boundsRect.right - (*AlertResHandle)->boundsRect.left);
(*AlertResHandle)->boundsRect = tempRect; /* Place the centered position back in the template */
FirstTime = TRUE; /* Set the flag for the filter proc */
/* Let the OS handle the Alert and wait for a result to be returned */
itemHit = NoteAlert(Res_A_Life_Alert, &MyFilter); /* Bring in the alert resource */
HUnlock((Handle)AlertResHandle); /* Release the alert handle to float */
/* This is the default selection, when RETURN is pressed. */
if (Res_Alrt_ReEnter == itemHit) /* See if this Button was selected */
{
}
A_Hit_Life_Alert(itemHit); /* Tell the user routine which item was selected */
} /* End of procedure */